home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / BBS-Archive / Dev / gcc263-src.lha / gcc-2.6.3 / libgcc1.c < prev    next >
C/C++ Source or Header  |  1994-04-28  |  12KB  |  609 lines

  1. /* Subroutines needed by GCC output code on some machines.  */
  2. /* Compile this file with the Unix C compiler!  */
  3. /* Copyright (C) 1987, 1988, 1992, 1994 Free Software Foundation, Inc.
  4.  
  5. This file is free software; you can redistribute it and/or modify it
  6. under the terms of the GNU General Public License as published by the
  7. Free Software Foundation; either version 2, or (at your option) any
  8. later version.
  9.  
  10. In addition to the permissions in the GNU General Public License, the
  11. Free Software Foundation gives you unlimited permission to link the
  12. compiled version of this file with other programs, and to distribute
  13. those programs without any restriction coming from the use of this
  14. file.  (The General Public License restrictions do apply in other
  15. respects; for example, they cover modification of the file, and
  16. distribution when not linked into another program.)
  17.  
  18. This file is distributed in the hope that it will be useful, but
  19. WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  21. General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program; see the file COPYING.  If not, write to
  25. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  26.  
  27. /* As a special exception, if you link this library with other files,
  28.    some of which are compiled with GCC, to produce an executable,
  29.    this library does not by itself cause the resulting executable
  30.    to be covered by the GNU General Public License.
  31.    This exception does not however invalidate any other reasons why
  32.    the executable file might be covered by the GNU General Public License.  */
  33.  
  34. #include "config.h"
  35.  
  36. /* Don't use `fancy_abort' here even if config.h says to use it.  */
  37. #ifdef abort
  38. #undef abort
  39. #endif
  40.  
  41. /* On some machines, cc is really GCC.  For these machines, we can't
  42.    expect these functions to be properly compiled unless GCC open codes
  43.    the operation (which is precisely when the function won't be used).
  44.    So allow tm.h to specify ways of accomplishing the operations
  45.    by defining the macros perform_*.
  46.  
  47.    On a machine where cc is some other compiler, there is usually no
  48.    reason to define perform_*.  The other compiler normally has other ways
  49.    of implementing all of these operations.
  50.  
  51.    In some cases a certain machine may come with GCC installed as cc
  52.    or may have some other compiler.  Then it may make sense for tm.h
  53.    to define perform_* only if __GNUC__ is defined.  */
  54.  
  55. #ifndef perform_mulsi3
  56. #define perform_mulsi3(a, b) return a * b
  57. #endif
  58.  
  59. #ifndef perform_divsi3
  60. #define perform_divsi3(a, b) return a / b
  61. #endif
  62.  
  63. #ifndef perform_udivsi3
  64. #define perform_udivsi3(a, b) return a / b
  65. #endif
  66.  
  67. #ifndef perform_modsi3
  68. #define perform_modsi3(a, b) return a % b
  69. #endif
  70.  
  71. #ifndef perform_umodsi3
  72. #define perform_umodsi3(a, b) return a % b
  73. #endif
  74.  
  75. #ifndef perform_lshrsi3
  76. #define perform_lshrsi3(a, b) return a >> b
  77. #endif
  78.  
  79. #ifndef perform_lshlsi3
  80. #define perform_lshlsi3(a, b) return a << b
  81. #endif
  82.  
  83. #ifndef perform_ashrsi3
  84. #define perform_ashrsi3(a, b) return a >> b
  85. #endif
  86.  
  87. #ifndef perform_ashlsi3
  88. #define perform_ashlsi3(a, b) return a << b
  89. #endif
  90.  
  91. #ifndef perform_adddf3
  92. #define perform_adddf3(a, b) return a + b
  93. #endif
  94.  
  95. #ifndef perform_subdf3
  96. #define perform_subdf3(a, b) return a - b
  97. #endif
  98.  
  99. #ifndef perform_muldf3
  100. #define perform_muldf3(a, b) return a * b
  101. #endif
  102.  
  103. #ifndef perform_divdf3
  104. #define perform_divdf3(a, b) return a / b
  105. #endif
  106.  
  107. #ifndef perform_addsf3
  108. #define perform_addsf3(a, b) return INTIFY (a + b)
  109. #endif
  110.  
  111. #ifndef perform_subsf3
  112. #define perform_subsf3(a, b) return INTIFY (a - b)
  113. #endif
  114.  
  115. #ifndef perform_mulsf3
  116. #define perform_mulsf3(a, b) return INTIFY (a * b)
  117. #endif
  118.  
  119. #ifndef perform_divsf3
  120. #define perform_divsf3(a, b) return INTIFY (a / b)
  121. #endif
  122.  
  123. #ifndef perform_negdf2
  124. #define perform_negdf2(a) return -a
  125. #endif
  126.  
  127. #ifndef perform_negsf2
  128. #define perform_negsf2(a) return INTIFY (-a)
  129. #endif
  130.  
  131. #ifndef perform_fixdfsi
  132. #define perform_fixdfsi(a) return (nongcc_SI_type) a;
  133. #endif
  134.  
  135. #ifndef perform_fixsfsi
  136. #define perform_fixsfsi(a) return (nongcc_SI_type) a
  137. #endif
  138.  
  139. #ifndef perform_floatsidf
  140. #define perform_floatsidf(a) return (double) a
  141. #endif
  142.  
  143. #ifndef perform_floatsisf
  144. #define perform_floatsisf(a)  return INTIFY ((float) a)
  145. #endif
  146.  
  147. #ifndef perform_extendsfdf2
  148. #define perform_extendsfdf2(a)  return a
  149. #endif
  150.  
  151. #ifndef perform_truncdfsf2
  152. #define perform_truncdfsf2(a)  return INTIFY (a)
  153. #endif
  154.  
  155. /* Note that eqdf2 returns a value for "true" that is == 0,
  156.    nedf2 returns a value for "true" that is != 0,
  157.    gtdf2 returns a value for "true" that is > 0,
  158.    and so on.  */
  159.  
  160. #ifndef perform_eqdf2
  161. #define perform_eqdf2(a, b) return !(a == b)
  162. #endif
  163.  
  164. #ifndef perform_nedf2
  165. #define perform_nedf2(a, b) return a != b
  166. #endif
  167.  
  168. #ifndef perform_gtdf2
  169. #define perform_gtdf2(a, b) return a > b
  170. #endif
  171.  
  172. #ifndef perform_gedf2
  173. #define perform_gedf2(a, b) return (a >= b) - 1
  174. #endif
  175.  
  176. #ifndef perform_ltdf2
  177. #define perform_ltdf2(a, b) return -(a < b)
  178. #endif
  179.  
  180. #ifndef perform_ledf2
  181. #define perform_ledf2(a, b) return 1 - (a <= b)
  182. #endif
  183.  
  184. #ifndef perform_eqsf2
  185. #define perform_eqsf2(a, b) return !(a == b)
  186. #endif
  187.  
  188. #ifndef perform_nesf2
  189. #define perform_nesf2(a, b) return a != b
  190. #endif
  191.  
  192. #ifndef perform_gtsf2
  193. #define perform_gtsf2(a, b) return a > b
  194. #endif
  195.  
  196. #ifndef perform_gesf2
  197. #define perform_gesf2(a, b) return (a >= b) - 1
  198. #endif
  199.  
  200. #ifndef perform_ltsf2
  201. #define perform_ltsf2(a, b) return -(a < b)
  202. #endif
  203.  
  204. #ifndef perform_lesf2
  205. #define perform_lesf2(a, b) return 1 - (a <= b);
  206. #endif
  207.  
  208. /* Define the C data type to use for an SImode value.  */
  209.  
  210. #ifndef nongcc_SI_type
  211. #define nongcc_SI_type long int
  212. #endif
  213.  
  214. /* Define the C data type to use for a value of word size */
  215. #ifndef nongcc_word_type
  216. #define nongcc_word_type nongcc_SI_type
  217. #endif
  218.  
  219. /* Define the type to be used for returning an SF mode value
  220.    and the method for turning a float into that type.
  221.    These definitions work for machines where an SF value is
  222.    returned in the same register as an int.  */
  223.  
  224. #ifndef FLOAT_VALUE_TYPE  
  225. #define FLOAT_VALUE_TYPE int
  226. #endif
  227.  
  228. #ifndef INTIFY
  229. #define INTIFY(FLOATVAL)  (intify.f = (FLOATVAL), intify.i)
  230. #endif
  231.  
  232. #ifndef FLOATIFY
  233. #define FLOATIFY(INTVAL)  ((INTVAL).f)
  234. #endif
  235.  
  236. #ifndef FLOAT_ARG_TYPE
  237. #define FLOAT_ARG_TYPE union flt_or_int
  238. #endif
  239.  
  240. union flt_or_value { FLOAT_VALUE_TYPE i; float f; };
  241.  
  242. union flt_or_int { int i; float f; };
  243.  
  244.  
  245. #ifdef L_mulsi3
  246. nongcc_SI_type
  247. __mulsi3 (a, b)
  248.      nongcc_SI_type a, b;
  249. {
  250.   perform_mulsi3 (a, b);
  251. }
  252. #endif
  253.  
  254. #ifdef L_udivsi3
  255. nongcc_SI_type
  256. __udivsi3 (a, b)
  257.      unsigned nongcc_SI_type a, b;
  258. {
  259.   perform_udivsi3 (a, b);
  260. }
  261. #endif
  262.  
  263. #ifdef L_divsi3
  264. nongcc_SI_type
  265. __divsi3 (a, b)
  266.      nongcc_SI_type a, b;
  267. {
  268.   perform_divsi3 (a, b);
  269. }
  270. #endif
  271.  
  272. #ifdef L_umodsi3
  273. nongcc_SI_type
  274. __umodsi3 (a, b)
  275.      unsigned nongcc_SI_type a, b;
  276. {
  277.   perform_umodsi3 (a, b);
  278. }
  279. #endif
  280.  
  281. #ifdef L_modsi3
  282. nongcc_SI_type
  283. __modsi3 (a, b)
  284.      nongcc_SI_type a, b;
  285. {
  286.   perform_modsi3 (a, b);
  287. }
  288. #endif
  289.  
  290. #ifdef L_lshrsi3
  291. nongcc_SI_type
  292. __lshrsi3 (a, b)
  293.      unsigned nongcc_SI_type a, b;
  294. {
  295.   perform_lshrsi3 (a, b);
  296. }
  297. #endif
  298.  
  299. #ifdef L_lshlsi3
  300. nongcc_SI_type
  301. __lshlsi3 (a, b)
  302.      unsigned nongcc_SI_type a, b;
  303. {
  304.   perform_lshlsi3 (a, b);
  305. }
  306. #endif
  307.  
  308. #ifdef L_ashrsi3
  309. nongcc_SI_type
  310. __ashrsi3 (a, b)
  311.      nongcc_SI_type a, b;
  312. {
  313.   perform_ashrsi3 (a, b);
  314. }
  315. #endif
  316.  
  317. #ifdef L_ashlsi3
  318. nongcc_SI_type
  319. __ashlsi3 (a, b)
  320.      nongcc_SI_type a, b;
  321. {
  322.   perform_ashlsi3 (a, b);
  323. }
  324. #endif
  325.  
  326. #ifdef L_divdf3
  327. double
  328. __divdf3 (a, b)
  329.      double a, b;
  330. {
  331.   perform_divdf3 (a, b);
  332. }
  333. #endif
  334.  
  335. #ifdef L_muldf3
  336. double
  337. __muldf3 (a, b)
  338.      double a, b;
  339. {
  340.   perform_muldf3 (a, b);
  341. }
  342. #endif
  343.  
  344. #ifdef L_negdf2
  345. double
  346. __negdf2 (a)
  347.      double a;
  348. {
  349.   perform_negdf2 (a);
  350. }
  351. #endif
  352.  
  353. #ifdef L_adddf3
  354. double
  355. __adddf3 (a, b)
  356.      double a, b;
  357. {
  358.   perform_adddf3 (a, b);
  359. }
  360. #endif
  361.  
  362. #ifdef L_subdf3
  363. double
  364. __subdf3 (a, b)
  365.      double a, b;
  366. {
  367.   perform_subdf3 (a, b);
  368. }
  369. #endif
  370.  
  371. /* Note that eqdf2 returns a value for "true" that is == 0,
  372.    nedf2 returns a value for "true" that is != 0,
  373.    gtdf2 returns a value for "true" that is > 0,
  374.    and so on.  */
  375.  
  376. #ifdef L_eqdf2
  377. nongcc_word_type
  378. __eqdf2 (a, b)
  379.      double a, b;
  380. {
  381.   /* Value == 0 iff a == b.  */
  382.   perform_eqdf2 (a, b);
  383. }
  384. #endif
  385.  
  386. #ifdef L_nedf2
  387. nongcc_word_type
  388. __nedf2 (a, b)
  389.      double a, b;
  390. {
  391.   /* Value != 0 iff a != b.  */
  392.   perform_nedf2 (a, b);
  393. }
  394. #endif
  395.  
  396. #ifdef L_gtdf2
  397. nongcc_word_type
  398. __gtdf2 (a, b)
  399.      double a, b;
  400. {
  401.   /* Value > 0 iff a > b.  */
  402.   perform_gtdf2 (a, b);
  403. }
  404. #endif
  405.  
  406. #ifdef L_gedf2
  407. nongcc_word_type
  408. __gedf2 (a, b)
  409.      double a, b;
  410. {
  411.   /* Value >= 0 iff a >= b.  */
  412.   perform_gedf2 (a, b);
  413. }
  414. #endif
  415.  
  416. #ifdef L_ltdf2
  417. nongcc_word_type
  418. __ltdf2 (a, b)
  419.      double a, b;
  420. {
  421.   /* Value < 0 iff a < b.  */
  422.   perform_ltdf2 (a, b);
  423. }
  424. #endif
  425.  
  426. #ifdef L_ledf2
  427. nongcc_word_type
  428. __ledf2 (a, b)
  429.      double a, b;
  430. {
  431.   /* Value <= 0 iff a <= b.  */
  432.   perform_ledf2 (a, b);
  433. }
  434. #endif
  435.  
  436. #ifdef L_fixdfsi
  437. nongcc_SI_type
  438. __fixdfsi (a)
  439.      double a;
  440. {
  441.   perform_fixdfsi (a);
  442. }
  443. #endif
  444.  
  445. #ifdef L_fixsfsi
  446. nongcc_SI_type
  447. __fixsfsi (a)
  448.      FLOAT_ARG_TYPE a;
  449. {
  450.   union flt_or_value intify;
  451.   perform_fixsfsi (FLOATIFY (a));
  452. }
  453. #endif
  454.  
  455. #ifdef L_floatsidf
  456. double
  457. __floatsidf (a)
  458.      nongcc_SI_type a;
  459. {
  460.   perform_floatsidf (a);
  461. }
  462. #endif
  463.  
  464. #ifdef L_floatsisf
  465. FLOAT_VALUE_TYPE
  466. __floatsisf (a)
  467.      nongcc_SI_type a;
  468. {
  469.   union flt_or_value intify;
  470.   perform_floatsisf (a);
  471. }
  472. #endif
  473.  
  474. #ifdef L_addsf3
  475. FLOAT_VALUE_TYPE
  476. __addsf3 (a, b)
  477.      FLOAT_ARG_TYPE a, b;
  478. {
  479.   union flt_or_value intify;
  480.   perform_addsf3 (FLOATIFY (a), FLOATIFY (b));
  481. }
  482. #endif
  483.  
  484. #ifdef L_negsf2
  485. FLOAT_VALUE_TYPE
  486. __negsf2 (a)
  487.      FLOAT_ARG_TYPE a;
  488. {
  489.   union flt_or_value intify;
  490.   perform_negsf2 (FLOATIFY (a));
  491. }
  492. #endif
  493.  
  494. #ifdef L_subsf3
  495. FLOAT_VALUE_TYPE
  496. __subsf3 (a, b)
  497.      FLOAT_ARG_TYPE a, b;
  498. {
  499.   union flt_or_value intify;
  500.   perform_subsf3 (FLOATIFY (a), FLOATIFY (b));
  501. }
  502. #endif
  503.  
  504. #ifdef L_eqsf2
  505. nongcc_word_type
  506. __eqsf2 (a, b)
  507.      FLOAT_ARG_TYPE a, b;
  508. {
  509.   union flt_or_int intify;
  510.   /* Value == 0 iff a == b.  */
  511.   perform_eqsf2 (FLOATIFY (a), FLOATIFY (b));
  512. }
  513. #endif
  514.  
  515. #ifdef L_nesf2
  516. nongcc_word_type
  517. __nesf2 (a, b)
  518.      FLOAT_ARG_TYPE a, b;
  519. {
  520.   union flt_or_int intify;
  521.   /* Value != 0 iff a != b.  */
  522.   perform_nesf2 (FLOATIFY (a), FLOATIFY (b));
  523. }
  524. #endif
  525.  
  526. #ifdef L_gtsf2
  527. nongcc_word_type
  528. __gtsf2 (a, b)
  529.      FLOAT_ARG_TYPE a, b;
  530. {
  531.   union flt_or_int intify;
  532.   /* Value > 0 iff a > b.  */
  533.   perform_gtsf2 (FLOATIFY (a), FLOATIFY (b));
  534. }
  535. #endif
  536.  
  537. #ifdef L_gesf2
  538. nongcc_word_type
  539. __gesf2 (a, b)
  540.      FLOAT_ARG_TYPE a, b;
  541. {
  542.   union flt_or_int intify;
  543.   /* Value >= 0 iff a >= b.  */
  544.   perform_gesf2 (FLOATIFY (a), FLOATIFY (b));
  545. }
  546. #endif
  547.  
  548. #ifdef L_ltsf2
  549. nongcc_word_type
  550. __ltsf2 (a, b)
  551.      FLOAT_ARG_TYPE a, b;
  552. {
  553.   union flt_or_int intify;
  554.   /* Value < 0 iff a < b.  */
  555.   perform_ltsf2 (FLOATIFY (a), FLOATIFY (b));
  556. }
  557. #endif
  558.  
  559. #ifdef L_lesf2
  560. nongcc_word_type
  561. __lesf2 (a, b)
  562.      FLOAT_ARG_TYPE a, b;
  563. {
  564.   union flt_or_int intify;
  565.   /* Value <= 0 iff a <= b.  */
  566.   perform_lesf2 (FLOATIFY (a), FLOATIFY (b));
  567. }
  568. #endif
  569.  
  570. #ifdef L_mulsf3
  571. FLOAT_VALUE_TYPE
  572. __mulsf3 (a, b)
  573.      FLOAT_ARG_TYPE a, b;
  574. {
  575.   union flt_or_value intify;
  576.   perform_mulsf3 (FLOATIFY (a), FLOATIFY (b));
  577. }
  578. #endif
  579.  
  580. #ifdef L_divsf3
  581. FLOAT_VALUE_TYPE
  582. __divsf3 (a, b)
  583.      FLOAT_ARG_TYPE a, b;
  584. {
  585.   union flt_or_value intify;
  586.   perform_divsf3 (FLOATIFY (a), FLOATIFY (b));
  587. }
  588. #endif
  589.  
  590. #ifdef L_truncdfsf2
  591. FLOAT_VALUE_TYPE
  592. __truncdfsf2 (a)
  593.      double a;
  594. {
  595.   union flt_or_value intify;
  596.   perform_truncdfsf2 (a);
  597. }
  598. #endif
  599.  
  600. #ifdef L_extendsfdf2
  601. double
  602. __extendsfdf2 (a)
  603.      FLOAT_ARG_TYPE a;
  604. {
  605.   union flt_or_value intify;
  606.   perform_extendsfdf2 (FLOATIFY (a));
  607. }
  608. #endif
  609.